// pages/passRecovery/passRecovery.js

//获取app实例
const app = getApp();

Page({

  /**
   * 页面的初始数据
   */
  data: {
    time: 60, //定时器总秒数
    disable: true  //按钮状态
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {

  },

  //找回支付密码
  mobileInputEvent: function (e) {
    this.setData({
      // 手机号码
      mobile: e.detail.value
    })
  },
  getMsgCode(e) {
    let time = this.data.time, //定时器秒数
      timer; //定时器
    const userId = app.globalData.userId;
    var mobile = this.data.mobile;
    var regMobile = /^1[23456789]\d{9}$/;
  },

  //跳转设置手机号
  formSubmit(e) {
    const userId = app.globalData.userId,
      mobile = e.detail.value.mobile,
      code = e.detail.value.code,
      regMobile = /^1[23456789]\d{9}$/;
    if (!mobile) {
      this.toast('请输入手机号')
      return false;
    }
    if (!regMobile.test(mobile)) {
      this.toast('手机号有误')
      return false;
    }
    wx.request({
      url: app.baseURL + 'Mine&a=reg&user_id=' + userId + '&mobile=' + mobile,
      success: (res) => {
        let data = res.data;
        console.log(data)
        if (data.status === 0) {
          this.toast(data.info);
        } else if (data.status === 1) {
          this.toast(data.info, true);
          setTimeout(() => {
            wx.navigateBack();
          }, 1000);
        }
      }
    })
  },
  toast(msg, isico) {
    wx.showToast({
      title: msg,
      icon: isico ? 'success' : 'none'
    })
  }
})